#include "Robot.h"

Robot::Robot() {
}

Robot::~Robot() {
}

void Robot::mouseMove(int x, int y) const {
	SetCursorPos(x, y);
}

void Robot::mousePress(DWORD buttonMask) const {
	INPUT input;
	MOUSEINPUT mouseInput;
	if(buttonMask == LEFT_BUTTON_MASK) {
		mouseInput.dwFlags = MOUSEEVENTF_LEFTDOWN;
	} else if(buttonMask == RIGHT_BUTTON_MASK) {
		mouseInput.dwFlags = MOUSEEVENTF_RIGHTDOWN;
	} else {
		return;
	}
	mouseInput.time = 0;
	input.type = INPUT_MOUSE;
	input.mi = mouseInput;
	SendInput(1, &input, sizeof(input));
}

void Robot::mouseRelease(DWORD buttonMask) const {
	INPUT input;
	MOUSEINPUT mouseInput;
	if(buttonMask == LEFT_BUTTON_MASK) {
		mouseInput.dwFlags = MOUSEEVENTF_LEFTUP;
	} else if(buttonMask == RIGHT_BUTTON_MASK) {
		mouseInput.dwFlags = MOUSEEVENTF_RIGHTUP;
	} else {
		return;
	}
	mouseInput.time = 0;
	input.type = INPUT_MOUSE;
	input.mi = mouseInput;
	SendInput(1, &input, sizeof(input));
}
void Robot::mouseWheel(int dist) const {
	INPUT input;
	MOUSEINPUT mouseInput;
	mouseInput.dwFlags = MOUSEEVENTF_WHEEL;
	mouseInput.time = 0;
	mouseInput.mouseData = dist * WHEEL_DELTA;
	input.type = INPUT_MOUSE;
	input.mi = mouseInput;
	SendInput(1, &input, sizeof(input));
}
